package api

import (
	"360-cinema/api-getaway/basic/config"
	"360-cinema/api-getaway/basic/handler/request"
	__ "360-cinema/api-getaway/basic/videoProto"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func VideoList(c *gin.Context) {
	var video request.VideoList
	err := c.ShouldBind(&video)
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code": 0,
			"msg":  "参数错误",
		})
		return
	}
	r, err := config.VideoClient.VideoList(c, &__.VideoListReq{
		Page: int64(video.Page),
		Size: int64(video.Size),
	})
	if err != nil {
		return
	}
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	c.JSON(http.StatusOK, gin.H{
		"UserId":      r.UserId,
		"Title":       r.Title,
		"Description": r.Description,
		"CoverUrl":    r.CoverUrl,
		"FileUrl":     r.FileUrl,
		"Type":        r.Type,
		"Address":     r.Address,
		"Year":        r.Year,
		"Play":        r.Play,
		"Like":        r.Like,
		"Collect":     r.Collect,
		"Comment":     r.Comment,
		"Status":      r.Status,
		"Reject":      r.Reject,
	})
}
